﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace School
{
    public class Course
    {
        private static int maxSize;
        private HashSet<Student> attendingStudents;
        private string name;

        static Course()
        {
            maxSize = 30;
        }

        public Course(string name)
        {
            this.name = name;
            attendingStudents = new HashSet<Student>();
        }

        public IEnumerable<Student> AttendingStudents
        {
            get
            {
                return attendingStudents;
            }
        }

        public static int MaxSize
        {
            get
            {
                return maxSize;
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
        }

        public int StudentCount
        {
            get
            {
                return attendingStudents.Count;
            }
        }

        public void AddStudent(Student student)
        {
            if (attendingStudents.Contains(student))
            {
                throw new ArgumentException("Cannot duplicate student!");
            }
            if (StudentCount >= Course.maxSize)
            {
                throw new OverflowException("Course is full!");
            }
            attendingStudents.Add(student);
        }

        public void RemoveStudent(Student student)
        {
            if (!attendingStudents.Contains(student))
            {
                throw new ArgumentException("Student is not in the course");
            }
            attendingStudents.Remove(student);
        }
    }
}
